Skip to content

Fix: Browser <title> tag is not rendered when overriding content_title in custom templates#7619

Merged
javiereguiluz merged 1 commit into
EasyCorp:4.xfrom
matixxd1999:patch-1
May 24, 2026
Merged

Fix: Browser <title> tag is not rendered when overriding content_title in custom templates#7619
javiereguiluz merged 1 commit into
EasyCorp:4.xfrom
matixxd1999:patch-1

Conversation

@matixxd1999
Copy link
Copy Markdown
Contributor

When creating a custom template that extends @EasyAdmin/page/content.html.twig and overriding the content_title block (as recommended by the deprecation notices), the browser's <title> tag remains empty.

…e in custom templates

When creating a custom template that extends @EasyAdmin/page/content.html.twig and overriding the content_title block (as recommended by the deprecation notices), the browser's <title> tag remains empty.
@javiereguiluz javiereguiluz added this to the 4.x milestone May 24, 2026
@javiereguiluz
Copy link
Copy Markdown
Collaborator

Thanks for fixing this bug @matixxd1999.

@javiereguiluz javiereguiluz merged commit 9c964aa into EasyCorp:4.x May 24, 2026
17 checks passed
@Seb33300
Copy link
Copy Markdown
Contributor

This fix looks weird to me.

On the same template we have:

{% block page_title %}{{ block('content_title') }}{% endblock %}
{% block content_title %}{{ block('page_title') }}{% endblock %}

@matixxd1999
Copy link
Copy Markdown
Contributor Author

Hey @Seb33300, I agree it looks like a circular dependency at first glance!

However, it's a necessary "Twig bridge" to maintain backward compatibility without breaking the layout. Because Twig evaluates the final overridden block from the child template first, it doesn't cause an infinite loop. It just links both blocks depending on what the user overrides:

  • If you use the new way (content_title): page_title acts as a proxy and passes your text up to the browser's <title> tag in layout.html.twig.
  • If you use the legacy way (page_title): content_title acts as a proxy and passes your text to the <h1> tag inside the content body.

Without this, the previously empty page_title block was just swallowing the value and leaving the browser tab completely blank when using content_title!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants